package demo.academique;

import org.omg.CosNaming.*;

public class Server {
	public static void main(String[] args) {
		org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
		try {
			org.omg.PortableServer.Servant servant;
			org.omg.CORBA.Object o;

			org.omg.PortableServer.POA poa = org.omg.PortableServer.POAHelper
					.narrow(orb.resolve_initial_references("RootPOA"));
			poa.the_POAManager().activate();

			// Servant de type TextMessage
			servant = new EtudiantImpl();
			o = poa.servant_to_reference(servant);

			// Servant de type MyServer
			servant = new RegistraireImpl(o);
			o = poa.servant_to_reference(servant);

			// register server with naming context
			NamingContextExt nc = NamingContextExtHelper.narrow(orb
					.resolve_initial_references("NameService"));
			NameComponent[] name = new NameComponent[] { new NameComponent(
					"Registraire", "service") };
			nc.rebind(name, o);
		} catch (Exception e) {
			e.printStackTrace();
		}
		orb.run();
	}
}
